<template>
	<view class="container">
		<u-navbar title-size="34" title="出售记录" leftIconColor="#343A40" title-color="#343A40" :border-bottom="false"
			leftIcon="arrow-left" :custom-back="goBack" placeholder>
		</u-navbar>
		<view class="order-wrap">
			<view>
				<view class="order-item" @tap="toWait(item)" v-for="item in allList" v-if="item.blind_box_id == 0">
					<view class="d-flex justify-content-between align-items-center transaction-time">
						<view class="text-999BA8 fz-22">交易时间: {{item.created_at}}</view>
					</view>
					<view class="d-flex position-relative" v-if="item.blind_box_id === 0">
						<view class="order-img">
							<image :src="item.works.cover" mode="aspectFill" v-if="item.works.cover"></image>
							<image :src="item.works.file" mode="aspectFill" v-else></image>
						</view>
						<view class="order-right position-relative d-flex justify-content-between align-items-center">
							<view class="order-name">{{item.works.name}}#{{item.market.no}}</view>
							<view class="order-amount">
								<view class="amount">
									<span class="fz-30">￥</span>
									<span class="fz-40 font-DIN">{{item.amount}}</span>
								</view>
								<view class="count font-DIN">
									x{{item.count}}
								</view>
							</view>
						</view>
					</view>
					<view class="d-flex position-relative" v-else>
						<view class="order-img">
							<image :src="item.box.cover_url" mode="aspectFill"></image>
						</view>
						<view class="order-right position-relative d-flex justify-content-between align-items-center">
							<view class="order-name">{{item.box.name}}</view>
							<view class="order-amount">
								<view class="amount">
									<span class="fz-30">￥</span>
									<span class="fz-40 font-DIN">{{item.amount}}</span>
								</view>
								<view class="count font-DIN">
									x{{item.count}}
								</view>
							</view>
						</view>
					</view>
				</view>
				<u-loadmore :status="allStatus" v-show="allLoading" margin-top="50" />
				<u-empty v-show="allTotal === 0 && !allLoading" color="#b5b5b5" src="/static/home/nodata-icon.png" margin-top="200"></u-empty>
			</view>
		</view>
	</view>
</template>

<script>
	export default{
		data(){
			return{
				allPage:1,
				allStatus:'loading',
				allLoading:false,
				allTotal:'',
				allList: [],
			}
		},
		onLoad(options) {
			this.getAll(1)
		},
		onReachBottom() {
			if(this.allList.length < this.allTotal){
				this.allPage ++
				this.getAll()
			}
		},
		methods:{
			goBack(){
				uni.switchTab({
					url:'/pages/tabBars/mine'
				})
			},
			//搜索全部订单
			getAll(val) {
				if(val == 1){
					this.allList = []
					this.allTotal = ''
					this.allPage = 1
				}
				this.allLoading = true
				this.allStatus = 'loading'
				this.$store.dispatch('wallet/orderSells', {page:this.allPage}).then(res => {
					this.allList = [...this.allList,...res.data.data]
					this.allTotal = res.data.total
					if(this.allList.length == this.allTotal && this.allList.length > 4){
						this.allStatus = 'nomore'
					}else{
						this.allLoading = false
					}
				})
			},
			//前往订单详情
			toWait(item){
				if(item.blind_box_id === 0){
					uni.navigateTo({
						url:`/pages/secondary/mine/order-cancel?created_at=${item.created_at}&price=${item.amount}&file=${item.works.file}&name=${item.works.name}&token_id=${item.works.token_id}&work_id=${item.work_id}&no=${item.market.no}&order_id=${item.id}&status=${item.status}&count=${item.count}&cover=${item.works.cover}&order_no=${item.order_no}`
					})
				}else{
					uni.navigateTo({
						url:`/pages/secondary/mine/order-cancel?created_at=${item.created_at}&price=${item.amount}&file=${item.box.cover_url}&name=${item.box.name}&order_id=${item.id}&work_id=${item.work_id}&status=${item.status}&count=${item.count}&order_no=${item.order_no}`
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container{
		width: 100%;
		min-height: 100vh;
		background: #F8F9FB;
	}
	.slot-wrap {
		display: flex;
		align-items: center;
		flex: 1;
		// padding-right: 30upx;
		box-sizing: border-box;
		.search-wrap {
			width: 90%;
			margin: 0 20rpx 0 0;
			/deep/.u-action-active{
				position: absolute;
				right:100upx;
				width: 110upx;
			}
			/deep/.u-action-active:before{
				width: 1upx;
				height: 30upx;
				background: #999BA8;
				position: absolute;
				content: '';
				left:0;
				top:6upx;
			}
			/deep/.u-close-wrap{
				position: absolute;
				right:110px !important;
			}
			/deep/.u-input{
				padding-right: 85px;
			}
		}
			
		.filter-icon{
			width: 44upx;
			height: 44upx;
			image{
				width: 44upx;
				height: 44upx;
			}
		}
	}
	.search-box {
		width: 100%;
		padding: 30upx 30upx 0 30upx;
		box-sizing: border-box;
		background: #ffffff;
		.delete-icon {
			width: 30upx;
			height: 30upx;
	
			image {
				width: 30upx;
				height: 30upx;
				vertical-align: top;
			}
		}
	}
	
	.order-wrap{
		width: 100%;
		padding: 24upx;
		box-sizing: border-box;
		.order-item{
			width: 702upx;
			// height: 341upx;
			background: #FFFFFF;
			box-shadow: 0px 4upx 30upx -12upx rgba(102,105,120,0.2), 0px 4upx 12upx -6upx rgba(154,166,219,0.1);
			border-radius: 10upx;
			margin-bottom: 20upx;
			box-sizing: border-box;
			padding: 24upx 30upx;
			.transaction-time{
				margin-bottom: 16upx;
			}
			.pay-time{
				padding-right: 12upx;
				height: 32upx;
				background: #F5F6F9;
				border-radius: 18upx;
				.pay-tip{
					width: 117upx;
					height: 32upx;
					background: #FF9D00;
					border-radius: 100upx 0px 74upx 100upx;
					margin-right:10upx;
					
				}
				.count-down-box{
					height: 32upx;
					display: flex;
					align-items: center;
				}
				/deep/.u-countdown-time{
					font-family: DIN !important;
					font-weight: bold !important;
				}
				/deep/.u-countdown-colon{
					line-height: 1em;
					font-size: 23upx;
					padding-bottom: 2upx !important;
				}
			}
			.order-img{
				width: 180upx;
				height: 180upx;
				border-radius: 8upx;
				margin-right: 18upx;
				image{
					width: 180upx;
					height: 180upx;
					border-radius: 8upx;
				}
			}
			.order-right{
				padding-top: 11upx;
				box-sizing: border-box;
				height: 180upx;
				width: 100%;
				.order-name{
					width: 57%;
					text-overflow: -o-ellipsis-lastline;
					overflow: hidden;				//溢出内容隐藏
					text-overflow: ellipsis;		//文本溢出部分用省略号表示
					display: -webkit-box;			//特别显示模式
					-webkit-line-clamp: 2;			//行数
					line-clamp: 2;					
					-webkit-box-orient: vertical;	//盒子中内容竖直排列
					word-wrap:break-word;
					word-break:break-all;
				}
				.order-amount{
					width: 41%;
					text-align: right;
					.amount{
						color: #2E2E4AFF;
					}
					.count{
						font-size: 28upx;
						color: #999BA8FF;
					}
				}
				.name-460{
					width: 460upx;
				}
				.order-price{
					bottom: 50upx;
				}
			}
			.btn{
				line-height: 58upx;
				width: 144upx;
				height: 58upx;
				border-radius: 29upx;
				margin-left: 24upx;
			}
		}
		
	}
</style>